package leetcode;

/**
 * @author noob
 * @version 1.0
 * @date 2021/3/20 6:25
 */
public class Solution303 {
    private SegmentTree2<Integer>  segmentTree;

    public void NumArray(int[] nums) {
        if(nums.length > 0){
            Integer[] data= new Integer[nums.length];
            for (int i = 0; i < nums.length; i++) {
                data[i] = nums[i];
            }
            segmentTree = new SegmentTree2<>(data,(a,b)->(a+b));
        }

    }

    public int sumRange(int left, int right) {

        return segmentTree.query(left,right);
    }
}
